﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;

namespace Galaxy.AutoCAD.Databases
{
    public static class CurveTool
    {
        #region 偏移曲线
        public static List<Curve> Offset(this Curve curve, double offsetValue)
        {
            ObjectId ModelSpaseID = SymbolUtilityServices.GetBlockModelSpaceId(HostApplicationServices.WorkingDatabase);
            List<Curve> result = new List<Curve>();
            try
            {
                DBObjectCollection offsetCurve = curve.GetOffsetCurves(offsetValue);
                foreach (var outCurve in offsetCurve)
                {
                    result.Add((Curve)outCurve);
                }
            }
            catch
            {
            }
            return result;
        }
        public static List<Curve> Offset(this Curve curve, Vector3d vec3d, double offsetValue)
        {
            ObjectId ModelSpaseID = SymbolUtilityServices.GetBlockModelSpaceId(HostApplicationServices.WorkingDatabase);
            List<Curve> result = new List<Curve>();
            try
            {
                DBObjectCollection offsetCurve = curve.GetOffsetCurvesGivenPlaneNormal(vec3d, offsetValue);
                foreach (var outCurve in offsetCurve)
                {
                    result.Add((Curve)outCurve);
                }
            }
            catch
            {
            }
            return result;
        }
        #endregion
    }
}
